package com.baseDemo.web.controller;



import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baseDemo.web.entity.AddressListEntity;
import com.baseDemo.web.service.addresslist.AddressListService;
import com.share.hibernate.baseDaoSupport.PageUtil;

@Controller
@RequestMapping(value = "addresslist", produces = "application/json;charset=UTF-8")
public class AddressListController {
	@Resource private AddressListService addressListService;
	
	@RequestMapping(value = "addAddressList.do")
	@ResponseBody
	public String addAddressList(@RequestBody @Valid AddressListEntity addressListEntity, BindingResult result,HttpServletRequest request) {
		return "{'id':'" + addressListService.addAddressList(addressListEntity,request) + "'}";
	}

	@RequestMapping(value = "/getAllByPage.do")
	public @ResponseBody
	PageUtil getAllByPage(@RequestParam("page") Integer page,
			@RequestParam("limit") Integer limit,
			@RequestParam("start") Integer start,HttpServletRequest request) {
		return addressListService.getListForPageToJson(start, limit,request);
	}
}
